home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!mailrus!ames!sun-barr!newstop!sun!harvard.harvard.edu!jimf%saber
- From: jimf%saber@harvard.harvard.edu
- Newsgroups: comp.sources.x
- Subject: v06i058: xloadimage, Patch5
- Message-ID: <133719@sun.Eng.Sun.COM>
- Date: 30 Mar 90 18:03:43 GMT
- Sender: news@sun.Eng.Sun.COM
- Lines: 1272
- Approved: argv@sun.com
-
- Submitted-by: jimf%saber@harvard.harvard.edu
- Posting-number: Volume 6, Issue 58
- Archive-name: xldimage/patch5
- Patch-To: xldimage: Volume 5, Issues 27,28,30
- Patch-To: xldimage: Volume 6, Issues 1,2
-
- Enclosed is part 1 of 1 of a patch to bring xloadimage version 1
- patchlevel 04 up to patchlevel 05. This patchlevel contains the
- following bug-fixes and enhancements:
-
- * Makefile enhancements for Saber-C users
- * The titlebar is now correct when halftoning
- * Greyscale Sun Rasterfiles are now supported
- * Fullscreen viewing is available with the -fullscreen option
- * Slideshow viewing is available with the -slideshow option
-
- To apply this patch, you should make a virgin patchlevel 04 directory
- and type "patch < patch.05" and hopefully you'll have an updated
- version a few seconds later.
-
- Enjoy,
-
- jim frost
- saber software
- jimf@saber.com
-
- -- cut here (src.PARTNUM.shar) --
-
- -- cut here (patch.05) --
- diff -c xloadimage.04/Makefile.std xloadimage.05/Makefile.std
- *** xloadimage.04/Makefile.std Fri Mar 2 19:02:00 1990
- --- xloadimage.05/Makefile.std Thu Feb 22 15:01:45 1990
- ***************
- *** 11,18 ****
- CP= cp
- LN= ln -s
- RM= rm -f
- -
- LIBS= -lX11
- OBJS= bright.o clip.o compress.o dither.o faces.o fill.o gif.o \
- halftone.o imagetypes.o merge.o misc.o new.o options.o path.o \
- pbm.o reduce.o root.o send.o sunraster.o value.o window.o \
- --- 11,23 ----
- CP= cp
- LN= ln -s
- RM= rm -f
- LIBS= -lX11
- +
- + SRCS= bright.c clip.c compress.c dither.c faces.c fill.c gif.c \
- + halftone.c imagetypes.c merge.c misc.c new.c options.c path.c \
- + pbm.c reduce.c root.c send.c sunraster.c value.c window.c \
- + xbitmap.c xloadimage.c xpixmap.c zio.c zoom.c
- +
- OBJS= bright.o clip.o compress.o dither.o faces.o fill.o gif.o \
- halftone.o imagetypes.o merge.o misc.o new.o options.o path.o \
- pbm.o reduce.o root.o send.o sunraster.o value.o window.o \
- ***************
- *** 46,48 ****
- --- 51,70 ----
- >> $(SYSPATHFILE)
- echo "extension=.csun .msun .sun .face .xbm .bm .gif" \
- >>$(SYSPATHFILE)
- +
- + # these targets are for those of us who have Saber-C
- +
- + # load all objects in saber. useful if you then swap the portions to debug
- + # for source.
- +
- + objinsaber:
- + #setopt ccargs -g -DSYSPATHFILE=\\\"$(SYSPATHFILE)\\\"
- + #load $(OBJS) $(LIBS)
- + #link
- +
- + # load all sources in saber. not as useful as the last one.
- +
- + srcinsaber:
- + #setopt load_flags -DSYSPATHFILE=\\\"$(SYSPATHFILE)\\\"
- + #load $(SRCS) $(LIBS)
- + #link
- diff -c xloadimage.04/README xloadimage.05/README
- *** xloadimage.04/README Fri Mar 2 19:02:01 1990
- --- xloadimage.05/README Sun Mar 18 18:14:39 1990
- ***************
- *** 140,142 ****
- --- 140,147 ----
- in send.c; this was fixed. A bug relating to -border and monochrome
- displays was fixed. There were several changes to the Imakefile and
- Makefiles.
- +
- + Patchlevel 05 contained enhancements to allow slideshows and
- + fullscreen viewing, some bug fixes related to scrolling around within
- + images, Saber-C makefile enhancements, a bug fix to the halftoning
- + title, and the addition of greyscale Sun Rasterfile support.
- diff -c xloadimage.04/clip.c xloadimage.05/clip.c
- *** xloadimage.04/clip.c Fri Mar 2 19:02:01 1990
- --- xloadimage.05/clip.c Fri Mar 2 15:50:29 1990
- ***************
- *** 55,61 ****
- startmask= 0x80 >> (clipx % 8);
- sline= simage->data + (slinelen * clipy);
- dline= image->data;
- - dp= image->data;
- for (y= 0; y < cliph; y++) {
- sp= sline + start;
- dp= dline;
- --- 55,60 ----
- diff -c xloadimage.04/halftone.c xloadimage.05/halftone.c
- *** xloadimage.04/halftone.c Fri Mar 2 19:02:04 1990
- --- xloadimage.05/halftone.c Wed Mar 14 18:23:47 1990
- ***************
- *** 68,74 ****
- image= newBitImage(cimage->width * 4, cimage->height * 4);
- if (cimage->title) {
- image->title= (char *)malloc(strlen(cimage->title) + 12);
- ! sprintf(image->title, "%s (dithered)", cimage->title);
- }
- spl= cimage->pixlen;
- dll= (image->width / 8) + (image->width % 8 ? 1 : 0);
- --- 68,74 ----
- image= newBitImage(cimage->width * 4, cimage->height * 4);
- if (cimage->title) {
- image->title= (char *)malloc(strlen(cimage->title) + 12);
- ! sprintf(image->title, "%s (halftoned)", cimage->title);
- }
- spl= cimage->pixlen;
- dll= (image->width / 8) + (image->width % 8 ? 1 : 0);
- diff -c xloadimage.04/image.h xloadimage.05/image.h
- *** xloadimage.04/image.h Fri Mar 2 19:02:04 1990
- --- xloadimage.05/image.h Sun Mar 18 15:19:30 1990
- ***************
- *** 88,100 ****
- void reduceRGBMap(); /* reduce.c */
- void reduce();
-
- - void imageOnRoot(); /* root.c */
- -
- unsigned long memToVal(); /* value.c */
- void valToMem();
- unsigned long memToValLSB();
- void valToMemLSB();
- -
- - void imageInWindow(); /* window.c */
-
- Image *zoom(); /* zoom.c */
- --- 88,96 ----
- diff -c xloadimage.04/misc.c xloadimage.05/misc.c
- *** xloadimage.04/misc.c Fri Mar 2 19:02:05 1990
- --- xloadimage.05/misc.c Sun Mar 18 17:32:06 1990
- ***************
- *** 20,25 ****
- --- 20,26 ----
- printf(" -onroot - load image onto root window\n");
- printf(" -border colorname - border image with this color\n");
- printf(" -display dispname - destination display\n");
- + printf(" -fullscreen - use entire screen for display\n");
- printf(" -geometry WxH+X+Y - destination size and location\n");
- printf(" -help - print this help message\n");
- printf(" -identify - identify given images\n");
- ***************
- *** 27,32 ****
- --- 28,34 ----
- printf(" -install - explicitly install colormap\n");
- printf(" -path - show image path for loading\n");
- printf(" -quiet - silence is golden\n");
- + printf(" -slideshow - show show images in slideshow style\n");
- printf(" -supported - show supported image types\n");
- printf(" -verbose - whistle while you work\n");
- printf(" -version - show version and patchlevel\n");
- ***************
- *** 81,88 ****
- options->clipw= image->width;
- if (!options->cliph)
- options->cliph= image->height;
- ! tmpimage= clip(image, options->clipx, options->clipy, options->clipw,
- ! options->cliph, verbose);
- freeImage(image);
- image= tmpimage;
- }
- --- 83,92 ----
- options->clipw= image->width;
- if (!options->cliph)
- options->cliph= image->height;
- ! tmpimage= clip(image, options->clipx, options->clipy,
- ! (options->clipw ? options->clipw : image->width),
- ! (options->cliph ? options->cliph : image->height),
- ! verbose);
- freeImage(image);
- image= tmpimage;
- }
- ***************
- *** 119,128 ****
- tmpimage= halftone(image, verbose);
- freeImage(image);
- image= tmpimage;
- - options->clipx *= 4; /* image was blown up by 4 */
- - options->clipy *= 4;
- - options->clipw *= 4;
- - options->cliph *= 4;
- }
- else if (!compressed) /* make sure colormap is minimized */
- compress(image, verbose);
- --- 123,128 ----
- diff -c xloadimage.04/new.c xloadimage.05/new.c
- *** xloadimage.04/new.c Fri Mar 2 19:02:06 1990
- --- xloadimage.05/new.c Fri Mar 9 14:32:22 1990
- ***************
- *** 89,94 ****
- --- 89,95 ----
- image->title= NULL;
- }
- freeRGBMapData(&(image->rgb));
- + lfree(image->data);
- }
-
- void freeImage(image)
- diff -c xloadimage.04/patchlevel xloadimage.05/patchlevel
- *** xloadimage.04/patchlevel Fri Mar 2 19:02:06 1990
- --- xloadimage.05/patchlevel Mon Mar 19 10:18:42 1990
- ***************
- *** 2,5 ****
- */
-
- #define VERSION "1"
- ! #define PATCHLEVEL "04"
- --- 2,5 ----
- */
-
- #define VERSION "1"
- ! #define PATCHLEVEL "05"
- diff -c xloadimage.04/path.c xloadimage.05/path.c
- *** xloadimage.04/path.c Fri Mar 2 19:02:07 1990
- --- xloadimage.05/path.c Fri Mar 16 10:55:38 1990
- ***************
- *** 10,19 ****
-
- #include "copyright.h"
- #include "xloadimage.h"
- ! #include <sys/file.h>
- ! #include <sys/types.h>
- #include <sys/stat.h>
- - #include <unistd.h>
- #include <pwd.h>
- #include <errno.h>
-
- --- 10,17 ----
-
- #include "copyright.h"
- #include "xloadimage.h"
- ! #include <X11/Xos.h>
- #include <sys/stat.h>
- #include <pwd.h>
- #include <errno.h>
-
- diff -c xloadimage.04/sunraster.c xloadimage.05/sunraster.c
- *** xloadimage.04/sunraster.c Fri Mar 2 19:02:08 1990
- --- xloadimage.05/sunraster.c Sun Mar 18 18:09:00 1990
- ***************
- *** 32,38 ****
- }
- printf(" %dx%d ", memToVal(header->width, 4), memToVal(header->height, 4));
- if (memToVal(header->depth, 4) > 1)
- ! printf("%d plane color", memToVal(header->depth, 4));
- else
- printf("monochrome");
- printf(" Sun rasterfile\n");
- --- 32,41 ----
- }
- printf(" %dx%d ", memToVal(header->width, 4), memToVal(header->height, 4));
- if (memToVal(header->depth, 4) > 1)
- ! printf("%d plane %s",
- ! memToVal(header->depth, 4),
- ! (memToVal(header->maplen, 4) > 0 ? "color" : "greyscale")
- ! );
- else
- printf("monochrome");
- printf(" Sun rasterfile\n");
- ***************
- *** 187,192 ****
- --- 190,198 ----
- else
- linelen= image->width * image->pixlen;
- fill= (linelen % 2 ? 1 : 0);
- + /*
- + * Handle color...
- + */
- if (mapsize= memToVal(header.maplen, 4)) {
- map= lmalloc(mapsize);
- if (zread(zf, map, mapsize) < mapsize) {
- ***************
- *** 205,210 ****
- --- 211,239 ----
- lfree(map);
- image->rgb.used= mapsize;
- }
- +
- + /*
- + * Handle 8-bit greyscale via a simple ramp function...
- + */
- + else if (depth > 1) {
- + mapsize = 256*3;
- + map= lmalloc(mapsize);
- + for (y = 0; y < 256; y += 1) {
- + map[y] = map[256+y] = map[2*256+y] = y;
- + }
- + mapsize /= 3;
- + mapred= map;
- + mapgreen= mapred + mapsize;
- + mapblue= mapgreen + mapsize;
- + for (y= 0; y < mapsize; y++) {
- + *(image->rgb.red + y)= (*(mapred++) << 8);
- + *(image->rgb.green + y)= (*(mapgreen++) << 8);
- + *(image->rgb.blue + y)= (*(mapblue++) << 8);
- + }
- + lfree(map);
- + image->rgb.used= mapsize;
- + }
- +
-
- enc= (memToVal(header.type, 4) == RRLENCODED);
- lineptr= image->data;
- Only in xloadimage.05: sunraster.c.orig
- diff -c xloadimage.04/window.c xloadimage.05/window.c
- *** xloadimage.04/window.c Fri Mar 2 19:02:09 1990
- --- xloadimage.05/window.c Sun Mar 18 18:04:01 1990
- ***************
- *** 10,17 ****
- --- 10,20 ----
-
- #include "copyright.h"
- #include "xloadimage.h"
- + #include <ctype.h>
- #include <X11/cursorfont.h>
-
- + static Window ImageWindow= 0;
- +
- static void setCursor(disp, window, iw, ih, ww, wh, cursor)
- Display *disp;
- Window window;
- ***************
- *** 33,55 ****
- *cursor= swa.cursor;
- }
-
- ! void imageInWindow(disp, scrn, image, winx, winy, winwidth, winheight, install,
- ! verbose)
- Display *disp;
- int scrn;
- Image *image;
- unsigned int winx, winy, winwidth, winheight;
- unsigned int install;
- unsigned int verbose;
- { Pixmap pixmap;
- Colormap xcmap;
- XSetWindowAttributes swa;
- XSizeHints sh;
- XGCValues gcv;
- GC gc;
- - Window window;
- int pixx, pixy;
- int lastx, lasty, mousex, mousey;
- union {
- XEvent event;
- XAnyEvent any;
- --- 36,140 ----
- *cursor= swa.cursor;
- }
-
- ! /* place an image
- ! */
- !
- ! static void placeImage(width, height, winwidth, winheight, rx, ry)
- ! int width, height, winwidth, winheight;
- ! int *rx, *ry; /* supplied and returned */
- ! { int pixx, pixy;
- !
- ! pixx= *rx;
- ! pixy= *ry;
- !
- ! if (winwidth > width)
- ! pixx= (winwidth - width) / 2;
- ! else {
- ! if ((pixx < 0) && (pixx + width < winwidth))
- ! pixx= winwidth - width;
- ! if (pixx > 0)
- ! pixx= 0;
- ! }
- ! if (winheight > height)
- ! pixy= (winheight - height) / 2;
- ! else {
- ! if ((pixy < 0) && (pixy + height < winheight))
- ! pixy= winheight - height;
- ! if (pixy > 0)
- ! pixy= 0;
- ! }
- ! *rx= pixx;
- ! *ry= pixy;
- ! }
- !
- ! /* blit an image
- ! */
- !
- ! static void blitImage(disp, pixmap, window, gc, pixx, pixy, width, height,
- ! winwidth, winheight, x, y, w, h)
- ! Display *disp;
- ! Pixmap pixmap;
- ! Window window;
- ! GC gc;
- ! int pixx, pixy, width, height, winwidth, winheight, x, y, w, h;
- ! {
- ! if (x + w > winwidth)
- ! w= winwidth - x;
- ! if (y + h > winheight)
- ! h= winheight - y;
- ! if (x < pixx) {
- ! XClearArea(disp, window, x, y, pixx - x, y + h, False);
- ! w -= (pixx - x);
- ! x= pixx;
- ! }
- ! if (y < pixy) {
- ! XClearArea(disp, window, x, y, w, pixy - y, False);
- ! h -= (pixy - y);
- ! y= pixy;
- ! }
- ! if (x + w > pixx + width) {
- ! XClearArea(disp, window, pixx + width, y, w - width, h, False);
- ! w= width;
- ! }
- ! if (y + h > pixy + height) {
- ! XClearArea(disp, window, x, pixy + height, w, h - height, False);
- ! h= height;
- ! }
- ! XCopyArea(disp, pixmap, ImageWindow, gc, x - pixx, y - pixy, w, h,
- ! x, y);
- ! }
- !
- ! /* clean up static window if we're through with it
- ! */
- !
- ! void cleanUpWindow(disp)
- ! Display *disp;
- ! {
- ! if (ImageWindow)
- ! XDestroyWindow(disp, ImageWindow);
- ! ImageWindow= 0;
- ! }
- !
- ! char imageInWindow(disp, scrn, image, winx, winy, winwidth, winheight,
- ! fullscreen, install, slideshow, verbose)
- Display *disp;
- int scrn;
- Image *image;
- unsigned int winx, winy, winwidth, winheight;
- + unsigned int fullscreen;
- unsigned int install;
- + unsigned int slideshow;
- unsigned int verbose;
- { Pixmap pixmap;
- Colormap xcmap;
- XSetWindowAttributes swa;
- XSizeHints sh;
- + XWMHints wmh;
- XGCValues gcv;
- GC gc;
- int pixx, pixy;
- int lastx, lasty, mousex, mousey;
- + int paint;
- union {
- XEvent event;
- XAnyEvent any;
- ***************
- *** 65,85 ****
- * we will not exceed 90% of display real estate.
- */
-
- ! lastx= (winwidth || winheight);
- ! if (!winwidth) {
- ! winwidth= image->width;
- ! if (winwidth > DisplayWidth(disp, scrn) * 0.9)
- ! winwidth= DisplayWidth(disp, scrn) * 0.9;
- }
- ! if (!winheight) {
- ! winheight= image->height;
- ! if (winheight > DisplayHeight(disp, scrn) * 0.9)
- ! winheight= DisplayHeight(disp, scrn) * 0.9;
- }
-
- if (! sendImageToX(disp, scrn, DefaultVisual(disp, scrn),
- image, &pixmap, &xcmap, verbose))
- exit(1);
- swa.backing_store= NotUseful;
- swa.bit_gravity= NorthWestGravity;
- swa.cursor= XCreateFontCursor(disp, XC_watch);
- --- 150,177 ----
- * we will not exceed 90% of display real estate.
- */
-
- ! if (fullscreen) {
- ! winwidth= DisplayWidth(disp, scrn);
- ! winheight= DisplayHeight(disp, scrn);
- }
- ! else {
- ! lastx= (winwidth || winheight); /* user set size flag */
- ! if (!winwidth) {
- ! winwidth= image->width;
- ! if (winwidth > DisplayWidth(disp, scrn) * 0.9)
- ! winwidth= DisplayWidth(disp, scrn) * 0.9;
- ! }
- ! if (!winheight) {
- ! winheight= image->height;
- ! if (winheight > DisplayHeight(disp, scrn) * 0.9)
- ! winheight= DisplayHeight(disp, scrn) * 0.9;
- ! }
- }
-
- if (! sendImageToX(disp, scrn, DefaultVisual(disp, scrn),
- image, &pixmap, &xcmap, verbose))
- exit(1);
- + swa.background_pixel= 0;
- swa.backing_store= NotUseful;
- swa.bit_gravity= NorthWestGravity;
- swa.cursor= XCreateFontCursor(disp, XC_watch);
- ***************
- *** 87,130 ****
- swa.event_mask= ButtonPressMask | Button1MotionMask | KeyPressMask |
- ExposureMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask;
- swa.save_under= False;
- ! window= XCreateWindow(disp, RootWindow(disp, scrn), 0, 0,
- ! image->width, image->height, 0,
- ! DefaultDepth(disp, scrn),
- ! InputOutput, CopyFromParent,
- ! CWBackingStore | CWBitGravity | CWCursor |
- ! CWColormap | CWEventMask | CWSaveUnder, &swa);
- ! XStoreName(disp, window, image->title);
- ! XSetIconName(disp, window, image->title);
-
- sh.width= winwidth;
- sh.height= winheight;
- ! sh.min_width= 1;
- ! sh.min_height= 1;
- ! sh.max_width= image->width;
- ! sh.max_height= image->height;
- sh.width_inc= 1;
- sh.height_inc= 1;
- sh.flags= PMinSize | PMaxSize | PResizeInc;
- ! if (lastx)
- sh.flags |= USSize;
- else
- sh.flags |= PSize;
- ! if (winx || winy) {
- sh.x= winx;
- sh.y= winy;
- sh.flags |= USPosition;
- }
- ! XSetNormalHints(disp, window, &sh);
-
- gcv.function= GXcopy;
- gcv.foreground= 0;
- ! gc= XCreateGC(disp, window, GCFunction | GCForeground, &gcv);
- ! XMapWindow(disp, window);
- ! pixx= pixy= 0;
- ! lastx= lasty= -1;
- ! setCursor(disp, window, image->width, image->height,
- winwidth, winheight, &(swa.cursor));
-
- for (;;) {
- XNextEvent(disp, &event);
- switch (event.any.type) {
- --- 179,249 ----
- swa.event_mask= ButtonPressMask | Button1MotionMask | KeyPressMask |
- ExposureMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask;
- swa.save_under= False;
- ! swa.override_redirect= (fullscreen ? True : False);
- ! if (!ImageWindow) {
- ! ImageWindow= XCreateWindow(disp, RootWindow(disp, scrn), 0, 0,
- ! winwidth, winheight, 0,
- ! DefaultDepth(disp, scrn),
- ! InputOutput, CopyFromParent,
- ! CWBackPixel | CWBackingStore |
- ! CWBitGravity | CWCursor | CWColormap |
- ! CWEventMask | CWSaveUnder, &swa);
- ! paint= 0;
- ! }
- ! else {
- ! XResizeWindow(disp, ImageWindow, winwidth, winheight);
- ! paint= 1;
- ! }
- ! XStoreName(disp, ImageWindow, image->title);
- ! XSetIconName(disp, ImageWindow, image->title);
-
- sh.width= winwidth;
- sh.height= winheight;
- ! if (fullscreen) {
- ! sh.min_width= sh.max_width= winwidth;
- ! sh.min_height= sh.max_height= winheight;
- ! }
- ! else {
- ! sh.min_width= 1;
- ! sh.min_height= 1;
- ! sh.max_width= image->width;
- ! sh.max_height= image->height;
- ! }
- sh.width_inc= 1;
- sh.height_inc= 1;
- sh.flags= PMinSize | PMaxSize | PResizeInc;
- ! if (lastx || fullscreen)
- sh.flags |= USSize;
- else
- sh.flags |= PSize;
- ! if (fullscreen) {
- ! sh.x= sh.y= 0;
- ! sh.flags |= USPosition;
- ! }
- ! else if (winx || winy) {
- sh.x= winx;
- sh.y= winy;
- sh.flags |= USPosition;
- }
- ! XSetNormalHints(disp, ImageWindow, &sh);
-
- + wmh.input= True;
- + wmh.flags= InputHint;
- + XSetWMHints(disp, ImageWindow, &wmh);
- +
- gcv.function= GXcopy;
- gcv.foreground= 0;
- ! gc= XCreateGC(disp, ImageWindow, GCFunction | GCForeground, &gcv);
- ! XMapWindow(disp, ImageWindow);
- ! placeImage(image->width, image->height, winwidth, winheight, &pixx, &pixy);
- ! if (paint)
- ! blitImage(disp, pixmap, ImageWindow, gc,
- ! pixx, pixy, image->width, image->height, winwidth, winheight,
- ! 0, 0, winwidth, winheight);
- ! setCursor(disp, ImageWindow, image->width, image->height,
- winwidth, winheight, &(swa.cursor));
-
- + lastx= lasty= -1;
- for (;;) {
- XNextEvent(disp, &event);
- switch (event.any.type) {
- ***************
- *** 140,157 ****
- char buf[128];
- KeySym ks;
- XComposeStatus status;
-
- XLookupString(&event.key,buf,128,&ks,&status);
- ! if (buf[0]=='q' || buf[0]=='Q') {
- ! XDestroyWindow(disp, window);
- ! XFreeCursor(disp, swa.cursor);
- ! XFreePixmap(disp, pixmap);
- if (xcmap != DefaultColormap(disp, scrn))
- XFreeColormap(disp, xcmap);
- ! return;
- }
- - }
- break;
-
- case MotionNotify:
- if ((image->width <= winwidth) && (image->height <= winheight))
- --- 259,290 ----
- char buf[128];
- KeySym ks;
- XComposeStatus status;
- + char ret;
- + Cursor cursor;
-
- XLookupString(&event.key,buf,128,&ks,&status);
- ! ret= buf[0];
- ! if (isupper(ret))
- ! ret= tolower(ret);
- ! switch (ret) {
- ! case 'n':
- ! case 'p':
- ! cursor= swa.cursor;
- ! swa.cursor= XCreateFontCursor(disp, XC_watch);
- ! XChangeWindowAttributes(disp, ImageWindow, CWCursor, &swa);
- ! XFreeCursor(disp, cursor);
- ! XFlush(disp);
- ! /* FALLTHRU */
- ! case '\003': /* ^C */
- ! case 'q':
- ! XFreeCursor(disp, swa.cursor);
- ! XFreePixmap(disp, pixmap);
- if (xcmap != DefaultColormap(disp, scrn))
- XFreeColormap(disp, xcmap);
- ! return(ret);
- }
- break;
- + }
-
- case MotionNotify:
- if ((image->width <= winwidth) && (image->height <= winheight))
- ***************
- *** 162,185 ****
- mousex= event.button.x;
- mousey= event.button.y;
- }
- ! pixx += lastx - mousex;
- ! pixy += lasty - mousey;
- lastx= mousex;
- lasty= mousey;
- ! if (image->width > winwidth) {
- ! if (pixx < 0)
- ! pixx= 0;
- ! if (pixx + winwidth > image->width)
- ! pixx= image->width - winwidth;
- ! }
- ! if (image->height > winheight) {
- ! if (pixy < 0)
- ! pixy= 0;
- ! if (pixy + winheight > image->height)
- ! pixy= image->height - winheight;
- ! }
- ! XCopyArea(disp, pixmap, window, gc,
- ! pixx, pixy, winwidth, winheight, 0, 0);
- break;
-
- case ConfigureNotify:
- --- 295,309 ----
- mousex= event.button.x;
- mousey= event.button.y;
- }
- ! pixx -= (lastx - mousex);
- ! pixy -= (lasty - mousey);
- lastx= mousex;
- lasty= mousey;
- ! placeImage(image->width, image->height, winwidth, winheight,
- ! &pixx, &pixy);
- ! blitImage(disp, pixmap, ImageWindow, gc,
- ! pixx, pixy, image->width, image->height, winwidth, winheight,
- ! 0, 0, winwidth, winheight);
- break;
-
- case ConfigureNotify:
- ***************
- *** 186,210 ****
- winwidth= event.configure.width;
- winheight= event.configure.height;
-
- /* configure the cursor to indicate which directions we can drag
- */
-
- ! if (pixx + winwidth > image->width)
- ! pixx= image->width - winwidth;
- ! if (pixy + winheight > image->height)
- ! pixy= image->height - winheight;
- ! if (winwidth > image->width)
- ! pixx= 0;
- ! if (winheight > image->height)
- ! pixy= 0;
- ! setCursor(disp, window, image->width, image->height,
- winwidth, winheight, &(swa.cursor));
-
- /* repaint
- */
-
- ! XCopyArea(disp, pixmap, window, gc,
- ! pixx, pixy, winwidth, winheight, 0, 0);
- break;
-
- case DestroyNotify:
- --- 310,330 ----
- winwidth= event.configure.width;
- winheight= event.configure.height;
-
- + placeImage(image->width, image->height, winwidth, winheight,
- + &pixx, &pixy);
- +
- /* configure the cursor to indicate which directions we can drag
- */
-
- ! setCursor(disp, ImageWindow, image->width, image->height,
- winwidth, winheight, &(swa.cursor));
-
- /* repaint
- */
-
- ! blitImage(disp, pixmap, ImageWindow, gc,
- ! pixx, pixy, image->width, image->height, winwidth, winheight,
- ! 0, 0, winwidth, winheight);
- break;
-
- case DestroyNotify:
- ***************
- *** 212,224 ****
- XFreePixmap(disp, pixmap);
- if (xcmap != DefaultColormap(disp, scrn))
- XFreeColormap(disp, xcmap);
- ! return;
-
- case Expose:
- ! XCopyArea(disp, pixmap, window, gc,
- ! pixx + event.expose.x, pixy + event.expose.y,
- ! event.expose.width, event.expose.height,
- ! event.expose.x, event.expose.y);
- break;
-
- case EnterNotify:
- --- 332,344 ----
- XFreePixmap(disp, pixmap);
- if (xcmap != DefaultColormap(disp, scrn))
- XFreeColormap(disp, xcmap);
- ! return('\0');
-
- case Expose:
- ! blitImage(disp, pixmap, ImageWindow, gc,
- ! pixx, pixy, image->width, image->height, winwidth, winheight,
- ! event.expose.x, event.expose.y,
- ! event.expose.width, event.expose.height);
- break;
-
- case EnterNotify:
- diff -c xloadimage.04/xbitmap.c xloadimage.05/xbitmap.c
- *** xloadimage.04/xbitmap.c Fri Mar 2 19:02:09 1990
- --- xloadimage.05/xbitmap.c Fri Mar 2 15:48:39 1990
- ***************
- *** 146,152 ****
-
- while (zgets(line, MAX_SIZE, zf)) {
- if (strlen(line) == MAX_SIZE-1) {
- ! fclose(zf);
- return(NULL);
- }
-
- --- 146,152 ----
-
- while (zgets(line, MAX_SIZE, zf)) {
- if (strlen(line) == MAX_SIZE-1) {
- ! zclose(zf);
- return(NULL);
- }
-
- diff -c xloadimage.04/xloadimage.c xloadimage.05/xloadimage.c
- *** xloadimage.04/xloadimage.c Fri Mar 2 19:02:10 1990
- --- xloadimage.05/xloadimage.c Sun Mar 18 17:40:42 1990
- ***************
- *** 12,18 ****
- #include "xloadimage.h"
- #include "patchlevel"
-
- ! /* options array and definitions
- */
-
- char *Options[] = {
- --- 12,19 ----
- #include "xloadimage.h"
- #include "patchlevel"
-
- ! /* options array and definitions. note that the enum values must be in the
- ! * same order as the options strings.
- */
-
- char *Options[] = {
- ***************
- *** 19,24 ****
- --- 20,26 ----
- "onroot", /* global options */
- "border",
- "display",
- + "fullscreen",
- "geometry",
- "help",
- "identify",
- ***************
- *** 26,31 ****
- --- 28,34 ----
- "install",
- "path",
- "quiet",
- + "slideshow",
- "supported",
- "verbose",
- "version",
- ***************
- *** 47,81 ****
- NULL
- };
-
- ! #define ONROOT 0
- ! #define BORDER 1
- ! #define DISPLAY 2
- ! #define GEOMETRY 3
- ! #define HELP 4
- ! #define IDENTIFY 5
- ! #define LIST 6
- ! #define INSTALL 7
- ! #define PATH 8
- ! #define QUIET 9
- ! #define SUPPORTED 10
- ! #define VERBOSE 11
- ! #define VER_NUM 12
- ! #define VIEW 13
-
- ! #define AT 14
- ! #define BACKGROUND 15
- ! #define BRIGHT 16
- ! #define CENTER 17
- ! #define CLIP 18
- ! #define COLORS 19
- ! #define DITHER 20
- ! #define FOREGROUND 21
- ! #define HALFTONE 22
- ! #define NAME 23
- ! #define XZOOM 24
- ! #define YZOOM 25
- ! #define ZOOM 26
-
- /* if an image loader needs to have our display and screen, it will get
- * them from here. this is done to keep most of the image routines
- * clean
- --- 50,70 ----
- NULL
- };
-
- ! enum {
-
- ! /* global options
- ! */
-
- + ONROOT= 0, BORDER, DISPLAY, FULLSCREEN, GEOMETRY, HELP, IDENTIFY, LIST,
- + INSTALL, PATH, QUIET, SLIDESHOW, SUPPORTED, VERBOSE, VER_NUM, VIEW,
- +
- + /* local options
- + */
- +
- + AT, BACKGROUND, BRIGHT, CENTER, CLIP, COLORS, DITHER, FOREGROUND,
- + HALFTONE, NAME, XZOOM, YZOOM, ZOOM
- + };
- +
- /* if an image loader needs to have our display and screen, it will get
- * them from here. this is done to keep most of the image routines
- * clean
- ***************
- *** 90,100 ****
- main(argc, argv)
- int argc;
- char *argv[];
- ! { unsigned int onroot= 1;
- char *border;
- char *dname;
- unsigned int identify;
- unsigned int install;
- unsigned int verbose;
- Image *dispimage; /* image that will be sent to the display */
- Image *newimage; /* new image we're loading */
- --- 79,91 ----
- main(argc, argv)
- int argc;
- char *argv[];
- ! { unsigned int onroot;
- char *border;
- char *dname;
- + unsigned int fullscreen;
- unsigned int identify;
- unsigned int install;
- + unsigned int slideshow;
- unsigned int verbose;
- Image *dispimage; /* image that will be sent to the display */
- Image *newimage; /* new image we're loading */
- ***************
- *** 102,109 ****
- int scrn; /* screen we're sending to */
- XColor xcolor; /* color for border option */
- ImageOptions images[MAXIMAGES]; /* list of image w/ options to load */
- unsigned int imagecount; /* number of images in ImageName array */
- - unsigned int a;
- unsigned int winx, winy; /* location of window */
- unsigned int winwidth, winheight; /* geometry of window */
-
- --- 93,100 ----
- int scrn; /* screen we're sending to */
- XColor xcolor; /* color for border option */
- ImageOptions images[MAXIMAGES]; /* list of image w/ options to load */
- + int a;
- unsigned int imagecount; /* number of images in ImageName array */
- unsigned int winx, winy; /* location of window */
- unsigned int winwidth, winheight; /* geometry of window */
-
- ***************
- *** 127,134 ****
- --- 118,127 ----
- }
- border= NULL;
- dname= NULL;
- + fullscreen= 0;
- identify= 0;
- install= 0;
- + slideshow= 0;
- winx= winy= winwidth= winheight= 0;
-
- imagecount= 0;
- ***************
- *** 178,183 ****
- --- 171,180 ----
- dname= argv[++a];
- break;
-
- + case FULLSCREEN:
- + fullscreen= 1;
- + break;
- +
- case GEOMETRY:
- XParseGeometry(argv[++a], &winx, &winy, &winwidth, &winheight);
- break;
- ***************
- *** 206,211 ****
- --- 203,212 ----
- verbose= 0;
- break;
-
- + case SLIDESHOW:
- + slideshow= 1;
- + break;
- +
- case SUPPORTED:
- supportedImageTypes();
- break;
- ***************
- *** 319,324 ****
- --- 320,335 ----
- exit(0);
- }
-
- + /* filter out mutually exclusive flags
- + */
- +
- + if (onroot && slideshow) {
- + printf("\
- + %s: -onroot and -slideshow are mutually exclusive (-onroot ignored)\n",
- + argv[0]);
- + onroot= 0;
- + }
- +
- /* start talking to the display
- */
-
- ***************
- *** 331,337 ****
-
- dispimage= NULL;
- if (onroot && (winwidth || winheight || images[0].center ||
- ! images[a].atx || images[a].aty)) {
- if (!winwidth)
- winwidth= DisplayWidth(disp, scrn);
- if (!winheight)
- --- 342,348 ----
-
- dispimage= NULL;
- if (onroot && (winwidth || winheight || images[0].center ||
- ! images[0].atx || images[0].aty)) {
- if (!winwidth)
- winwidth= DisplayWidth(disp, scrn);
- if (!winheight)
- ***************
- *** 380,392 ****
- ((dispimage && BITMAPP(dispimage)) || (DefaultDepth(disp, scrn) == 1)))
- images[a].dither= 2;
- newimage= processImage(disp, scrn, newimage, &images[a], verbose);
- - if (!images[a].clipw && !images[a].cliph) {
- - images[a].clipw= newimage->width;
- - images[a].cliph= newimage->height;
- - }
- if (images[a].center) {
- ! images[a].atx= (dispimage->width - images[a].clipw) / 2;
- ! images[a].aty= (dispimage->height - images[a].cliph) / 2;
- }
- if (dispimage) {
- if (! dispimage->title)
- --- 391,399 ----
- ((dispimage && BITMAPP(dispimage)) || (DefaultDepth(disp, scrn) == 1)))
- images[a].dither= 2;
- newimage= processImage(disp, scrn, newimage, &images[a], verbose);
- if (images[a].center) {
- ! images[a].atx= (dispimage->width - newimage->width) / 2;
- ! images[a].aty= (dispimage->height - newimage->height) / 2;
- }
- if (dispimage) {
- if (! dispimage->title)
- ***************
- *** 396,404 ****
- }
- else
- dispimage= newimage;
- }
-
- ! if (! dispimage) {
- printf("No images to display\n");
- exit(1);
- }
- --- 403,435 ----
- }
- else
- dispimage= newimage;
- + if (slideshow) {
- + switch(imageInWindow(disp, scrn, dispimage, winx, winy,
- + winwidth, winheight,
- + fullscreen, install, slideshow, verbose)) {
- + case '\0': /* window got nuked by someone */
- + XCloseDisplay(disp);
- + exit(1);
- + case '\003':
- + case 'q': /* user quit */
- + XCloseDisplay(disp);
- + exit(0);
- +
- + case 'n': /* next image */
- + break;
- + case 'p': /* previous image */
- + if (a > 0)
- + a -= 2;
- + else
- + a--;
- + break;
- + }
- + freeImage(dispimage);
- + dispimage= NULL;
- + }
- }
-
- ! if (!slideshow && !dispimage) {
- printf("No images to display\n");
- exit(1);
- }
- ***************
- *** 405,412 ****
-
- if (onroot)
- imageOnRoot(disp, scrn, dispimage, verbose);
- ! else
- ! imageInWindow(disp, scrn, dispimage, winx, winy, winwidth, winheight,
- ! install, verbose);
- XCloseDisplay(disp);
- }
- --- 436,446 ----
-
- if (onroot)
- imageOnRoot(disp, scrn, dispimage, verbose);
- ! else {
- ! if (!slideshow)
- ! imageInWindow(disp, scrn, dispimage, winx, winy, winwidth, winheight,
- ! fullscreen, install, slideshow, verbose);
- ! cleanUpWindow(disp);
- ! }
- XCloseDisplay(disp);
- }
- diff -c xloadimage.04/xloadimage.h xloadimage.05/xloadimage.h
- *** xloadimage.04/xloadimage.h Fri Mar 2 19:02:10 1990
- --- xloadimage.05/xloadimage.h Sun Mar 18 15:02:36 1990
- ***************
- *** 57,62 ****
- --- 57,67 ----
- void loadPathsAndExts();
- void showPath();
-
- + void imageOnRoot(); /* root.c */
- +
- unsigned int sendImageToX(); /* send.c */
-
- Visual *getBestVisual(); /* visual.c */
- +
- + void cleanUpWindow(); /* window.c */
- + char imageInWindow();
- diff -c xloadimage.04/xloadimage.man xloadimage.05/xloadimage.man
- *** xloadimage.04/xloadimage.man Fri Mar 2 19:02:11 1990
- --- xloadimage.05/xloadimage.man Mon Mar 19 10:28:08 1990
- ***************
- *** 28,40 ****
- for above accuracy.
- .PP
- If you are viewing a large image in a window, the initial window will
- ! be at most 90% of the size of the display (unless the window manager
- ! does not correctly handle window size requests). You may move the
- ! image around in the window by dragging with the first mouse button.
- ! The cursor will indicate which directions you may drag, if any. You
- ! may exit the window by typing 'q' or 'Q' when the keyboard focus is on
- ! the window.
- .PP
- A wide variety of common image manipulations can be done by mixing and
- matching the available options. See the section entitled \fIHINTS FOR
- GOOD IMAGE DISPLAYS\fR for some ideas.
- --- 28,43 ----
- for above accuracy.
- .PP
- If you are viewing a large image in a window, the initial window will
- ! be at most 90% of the size of the display unless the window manager
- ! does not correctly handle window size requests or if you've used the
- ! \fI-fullscreen\fR option. You may move the image around in the window
- ! by dragging with the first mouse button. The cursor will indicate
- ! which directions you may drag, if any. You may exit the window by
- ! typing 'q' or '^C' when the keyboard focus is on the window.
- .PP
- + It's possible to have a "slideshow" of many images by specifying the
- + \fI-slideshow\fR option.
- + .PP
- A wide variety of common image manipulations can be done by mixing and
- matching the available options. See the section entitled \fIHINTS FOR
- GOOD IMAGE DISPLAYS\fR for some ideas.
- ***************
- *** 52,57 ****
- --- 55,64 ----
- -display \fIdisplay_name\fR
- X11 display name to send the image(s) to.
- .TP
- + -fullscreen
- + Use the entire screen to display images. This option is incompatible
- + with -onroot.
- + .TP
- -geometry \fIWxH[{+-X}{+-}Y]\fR
- This sets the size of the window onto which the images are loaded to a
- different value than the size of the image. When viewing an image in
- ***************
- *** 88,93 ****
- --- 95,106 ----
- Forces \fIxloadimage\fR and \fIxview\fR to be quiet. This is the
- default for \fIxsetbg\fR, but the others like to whistle.
- .TP
- + -slideshow
- + Show each image argument one at a time instead of merging them.
- + Typing 'p' will back up to the previous image displayed, 'n' will go
- + to the next image, and 'q' or '^C' will quit. This option is often
- + used in conjunction with -fullscreen.
- + .TP
- -supported
- List the supported image types.
- .TP
- ***************
- *** 323,331 ****
- jimf@saber.com
- .fi
- .PP
- ! Other contributing people include Barry Shein (bzs@std.com), Kirk L.
- ! Johnson (tuna@athena.mit.edu), Mark Snitily (zok!mark@apple.com), and
- ! W. David Higgins (wdh@mkt.csd.harris.com).
- .SH FILES
- .nf
- .in +5
- --- 336,345 ----
- jimf@saber.com
- .fi
- .PP
- ! Other contributing people include Barry Shein (bzs@std.com), Kirk
- ! Johnson (tuna@athena.mit.edu), Mark Snitily (zok!mark@apple.com),
- ! W. David Higgins (wdh@mkt.csd.harris.com), and Dave Nelson
- ! (daven@gauss.llnl.gov).
- .SH FILES
- .nf
- .in +5
- ***************
- *** 333,339 ****
- xsetbg - pseudonym which quietly sets the background
- xview - pseudonym which views in a window
- /usr/lib/X11/Xloadimage - default system-wide configuration file
- ! \~/.xloadimagerc - user's personal configuration file
- .in -5
- .fi
- .SH COPYRIGHT
- --- 347,353 ----
- xsetbg - pseudonym which quietly sets the background
- xview - pseudonym which views in a window
- /usr/lib/X11/Xloadimage - default system-wide configuration file
- ! ~/.xloadimagerc - user's personal configuration file
- .in -5
- .fi
- .SH COPYRIGHT
-
- dan
- -----------------------------------------------------------
- O'Reilly && Associates
- argv@sun.com / argv@ora.com
- 632 Petaluma Ave, Sebastopol, CA 95472
- 800-338-NUTS, in CA: 800-533-NUTS, FAX 707-829-0104
- Opinions expressed reflect those of the author only.
-